package middleware

import "github.com/gin-gonic/gin"

func Auth() gin.HandlerFunc {
	return func(c *gin.Context) {
		cookie, e := c.Request.Cookie("cookie")
		if e == nil {
			c.SetCookie(cookie.Name, cookie.Value, 7200, cookie.Path, cookie.Domain, cookie.Secure, cookie.HttpOnly)
			c.Next()
		} else {
			c.Abort()
			c.JSON(200, gin.H{"code": 401, "message": "登录过期"})
		}
	}
}
